package com.aliyun.messagemgt.controller;

import com.aliyun.messagemgt.application.service.ChannelNoServer;
import com.aliyun.messagemgt.dto.ChannelNo;
import com.aliyun.messagemgt.dto.query.ChannelNoQuery;
import com.aliyun.messagemgt.web.controller.ChannelNoController;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.test.annotation.Rollback;

/**
 * @author wenyaxin
 * @date 2020/12/2
 */
@RunWith(MockitoJUnitRunner.class)
public class ChannelNoControllerTest {

    @InjectMocks
    private ChannelNoController channelNoController;

    @Mock
    private ChannelNoServer channelNoServer;

    @Test
    @Rollback()
    public void delChannelNoTest(){
        Mockito.when(channelNoServer.delChannelNo(Mockito.any())).thenReturn(1);
        channelNoController.delChannelNo(createChannelNoQuery());
    }

    @Test
    @Rollback()
    public void hiddenChannelNoTest(){
        Mockito.when(channelNoServer.hiddenChannelNo(Mockito.any())).thenReturn(1);
        channelNoController.hiddenChannelNo(createChannelNoQuery());
    }

    @Test
    @Rollback()
    public void modChannelNoTest(){
        Mockito.when(channelNoServer.modChannelNo(Mockito.any())).thenReturn(1);
        channelNoController.modChannelNo(createChannelNo());
    }

    @Test
    @Rollback()
    public void detailChannelNoTest(){
        Mockito.when(channelNoServer.detailChannelNo(Mockito.any())).thenReturn(1);
        channelNoController.detailChannelNo(createChannelNoQuery());
    }


    private ChannelNo createChannelNo(){
        ChannelNo channelNo = Mockito.mock(ChannelNo.class);
        return channelNo;
    }

    private ChannelNoQuery createChannelNoQuery(){
        ChannelNoQuery channelNoQuery = Mockito.mock(ChannelNoQuery.class);
        return channelNoQuery;
    }

}
